package com.kaibes.admin.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.kaibes.web.admin.AdminController;
import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ApiLinkService;

@AdminController
@RequestMapping("/admin/api-link")
public class ApiLinkController {
    
    @Autowired
    private ApiLinkService apiLinkService;
    
    /**
     * 
     * @param model 数据模型
     * @param userId 没有用到，但是有这个参数就会要求必须登录才能访问
     * @return
     */
    @ApiLink("接口查询")
    @GetMapping("/api")
    public String showApis(Model model, @RequestAttribute Integer userId) {
        model.addAttribute("apiList", apiLinkService.listApi());
        return "api";
    }
    
    @ApiLink("链接查询")
    @GetMapping("/link")
    public String adminLinks(Model model, @RequestAttribute Integer userId) {
        model.addAttribute("linkList", apiLinkService.listLink());
        return "link";
    }
    
}
